#include "platform.h"
#include "SoftUart.h"
#include "SoftI2C.h"


// #include "system.h"


// 指定以下代码的优化规则
#pragma GCC push_options
#pragma GCC optimize ("O1")


I2C_t  AHT10 ;
int32_t humidity ;
int32_t temperature ;

void main()
{


    // P_TXD = 1 ;
    *I2C_BASEADDR = 0xf ; // 仿真时需要
    LED = 0x0 ;
    SoftI2C_Init(&AHT10 ,I2C_BASEADDR ,     I2C0_PIN_SCL   ,I2C0_PIN_SDA , 250) ;
    SoftI2C_AHT10_Init(&AHT10 )  ;
    DEBUG_OUT = 0;
    TxStr("s") ;
	while(1){
                
        // DEBUG_OUT=DEBUG_OUT+1 ;
        // Serv_Delayms(2000) ;
        if(SoftI2C_AHT10_Get(&AHT10, &humidity , &temperature )) {
            TxStr("oky\r\n") ;
            TxInt16((temperature>>4)) ;
            LED = 1 ;
        } else {
            TxStr("Get failed\r\n") ;  
            LED = 0 ;
        }
        SoftI2C_AHT10_Run(&AHT10) ;
        Serv_Delayms(1000) ;

        
    }
	return;
}



#pragma GCC pop_options  // 结束不优化的代码
